package game.breeze.resource;

import game.breeze.Disposable;
import game.breeze.util.CommonUtils;
import jxl.Cell;

import org.apache.commons.lang.math.NumberUtils;
import org.dom4j.Document;
import org.dom4j.Element;

/**
 * 
 * Class desc there
 * 
 * @author yangwei ywengineer@gmail.com
 * 
 */
public abstract class GameObjectDef implements Disposable {
	protected int id;
	protected int x;
	protected int y;
	protected String name;

	public GameObjectDef() {
	}

	public GameObjectDef(Cell[] data) {
		this.id = NumberUtils.toInt(data[0].getContents());
		this.name = data[1].getContents();
	}

	public GameObjectDef(Document doc) {
		Element root = doc.getRootElement();
		id = NumberUtils.toInt(root.attributeValue("id"));
		x = NumberUtils.toInt(root.attributeValue("y"));
		y = NumberUtils.toInt(root.attributeValue("y"));
		name = root.attributeValue("name");
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @return the x
	 */
	public int getX() {
		return x;
	}

	/**
	 * @return the y
	 */
	public int getY() {
		return y;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @param x
	 *            the x to set
	 */
	public void setX(int x) {
		this.x = x;
	}

	/**
	 * @param y
	 *            the y to set
	 */
	public void setY(int y) {
		this.y = y;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return CommonUtils.desClass(this);
	}
}
